﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LogisticDatabase;
using LogisticDatabase.Models; 
  

namespace LogisticSimulator.Controllers
{
    public class CityController : Controller
    {
        IDataAccess<City> cityDataAccess;

        public CityController(IDataAccess<City> cityDataAccess)
        {
            this.cityDataAccess = cityDataAccess;
        }

        public ActionResult Index()
        {
            return RedirectToAction("List");
        }
        
        //
        // GET: /City/


        public ActionResult List()
        {
            
            //CityDataAccess cityDataAccess = new CityDataAccess();
            ViewBag.Cities = cityDataAccess.listAll();

            return View();
        
        }

        [HttpGet]
        public ActionResult Edit()
        {
            
            return View();
        }


        //olyan mint Javaba a doPost
        [HttpPost]
        public ActionResult Edit(City c)
        {
            /*string cityName = this.Request.QueryString["name"];
            string cityCountry = this.Request.QueryString["country"];*/

            //CityDataAccess cityDataAccess = new CityDataAccess();

            City city = new City { Country = c.Country, Name = c.Name };

            cityDataAccess.add(c);
            return View();
        }
	}
}